Machine learning-based prediction models affecting the recovery of postoperative bowel function for patients undergoing colorectal surgeries

Purpose The debate surrounding factors influencing postoperative flatus and defecation in patients undergoing colorectal resection prompted this study. Our objective was to identify independent risk factors and develop prediction models for postoperative bowel function in patients undergoing colorectal surgeries. Methods A retrospective analysis of medical records was conducted for patients who undergoing colorectal surgeries at Peking University People’s Hospital from January 2015 to October 2021. Machine learning algorithms were employed to identify risk factors and construct prediction models for the time of the first postoperative flatus and defecation. The prediction models were evaluated using sensitivity, specificity, the Youden index, and the area under the receiver operating characteristic curve (AUC) through logistic regression, random forest, Naïve Bayes, and extreme gradient boosting algorithms. Results The study included 1358 patients for postoperative flatus timing analysis and 1430 patients for postoperative defecation timing analysis between January 2015 and December 2020 as part of the training phase. Additionally, a validation set comprised 200 patients who undergoing colorectal surgeries from January to October 2021. The logistic regression prediction model exhibited the highest AUC (0.78) for predicting the timing of the first postoperative flatus. Identified independent risk factors influencing the time of first postoperative flatus were Age (p < 0.01), oral laxatives for bowel preparation (p = 0.01), probiotics (p = 0.02), oral antibiotics for bowel preparation (p = 0.02), duration of operation (p = 0.02), postoperative fortified antibiotics (p = 0.02), and time of first postoperative feeding (p < 0.01). Furthermore, logistic regression achieved an AUC of 0.72 for predicting the time of first postoperative defecation, with age (p < 0.01), oral antibiotics for bowel preparation (p = 0.01), probiotics (p = 0.01), and time of first postoperative feeding (p < 0.01) identified as independent risk factors. Conclusions The study suggests that he use of probiotics and early recovery of diet may enhance the recovery of bowel function in patients undergoing colorectal surgeries. Among the various analytical methods used, logistic regression emerged as the most effective approach for predicting the timing of the first postoperative flatus and defecation in this patient population. Supplementary Information The online version contains supplementary material available at 10.1186/s12893-024-02437-9.


Background
The recovery of bowel function after colorectal surgery has been extensively researched.Poor recovery of bowel function can lead to prolonged hospital stays, increased complications rates, higher hospitalization costs, and mortality [1,2].While stool form scales offer a straightforward approach to evaluating intestinal transit rate, they are not commonly utilized in clinical setting or research endeavors [3].Symptoms like nausea and/or vomiting, fecal urgency, and bowel movement are considered indicative signals of postoperative bowel function restoration [4].Time of first bowel motion, time of first postoperative flatus and defecation are employed to gauge postoperative bowel function for patients undergoing colorectal surgeries [5][6][7][8].
Numerous risk factors influence the recuperation of postoperative bowel function.Previous studies about recovery of bowel function following colorectal surgeries suggested that laparoscopic surgery may enhance postoperative bowel function recovery compared to traditional laparotomy [9].Mechanical bowel preparation had shown benefits in some studies, yet recent research indicated that it may not consistently improve patients' recovery and could lead to patients' discomfort [10].The outcomes concerning postoperative bowel function recovery remain contentious.Limited studies have delved into multivariate analysis of the time of the first postoperative flatus and defecation for patients undergoing colorectal surgeries.Furthermore, no study had developed a prediction model for postoperative bowel function recovery in this patient population.
This study aimed to establish prediction models using machine learning algorithms to assess the risks and identify independent risk factors associated with the time of first postoperative flatus and defecation for patients undergoing colorectal surgeries.

Participants
This study was approved by the Ethics committee of Peking University People's Hospital (2022PHB053-001, Beijing, China).A retrospective study was conducted to develop and internally validate the time of the first postoperative flatus and defecation.Adult patients undergoing colorectal surgeries at Peking University People's Hospital from January 2015 to October 2021 were enrolled.Exclusion criteria were patients who met one of the following characteristics: • Patients who had a history of surgical reconstruction of the digestive tract.• Patients who had undergone enterostomies, such as jejunostomy, total proctocolectomy with ileostomy, or colostomy.• Patients who were younger than 18 years old.
• Data on the time to postoperative flatus or/and defecation were incomplete.
Previous studies [11,12] found that the mean time of the first postoperative flatus was 4 days and the time of the first postoperative defecation was 5 days for patients undergoing colorectal surgeries.Therefore, we defined patients in two groups between the time of the first postoperative flatus within 4 days and more than 5 days.We defined patients in two groups between the time of the first postoperative defecation within 4 days and more than 5 days as well.

Data collection
General data of patients were carefully recorded, including age, gender, body mass index (BMI), history of alcohol, and history of smocking.Underlying disease (hypertension, coronary heart disease [CHD], arrhythmia, cerebral infraction, encephalorrhagia, hypothyroidism, diabetes, chronic obstructive pulmonary disease [COPD], renal inadequacy, hyperlipidemia, hepatic inadequacy, blood disease) diagnosed before admission were entered into excel of case report form (CRF). Data of preoperative chemotherapy, preoperative anemia, preoperative ileus, the American Society of Anesthesiologists (ASA) classification, bowel preparation before surgery (soapsuds enema, oral laxatives, glycerin enema, and oral antibiotics) were adopted in CRF.Data of surgery such as surgical site (right hemicolectomy, transverse colectomy, left hemicolectomy, sigmoid colectomy, and proctectomy), surgical approach (laparotomy or laparoscopic surgery), excision method (local resection or extended radical resection), duration of operation, antibiotics correlation (preoperative, fortified before surgery, fortified after surgery, duration of antibiotics) were entered into CRF.Postoperative data including time of the first postoperative feeding (day), probiotics correlation; postoperative albumin level, postoperative analgesia (no analgesia, opioids, opioids combine non-steroidal antiinflammatory drugs [NSAIDs], and take NSAIDs alone), duration of analgesia, time to the extraction of a gastric tube and the drainage tube were entered recorded.All data were obtained by medical record such as papery medical records library or electronic medical record system.

Univariate analysis
Univariate analysis was performed using SPSS 26.0 software (IBM, Armonk, NY, USA) to identify the relative risk factors affecting the time of first postoperative flatus and defecation by.Quantitative data with normal distribution were expressed as mean ± standard deviations (SD) or medians and interquartile ranges and compared using a one-way analysis of variance.Frequencies and percentages were used for categorical variables.An independent sample t-test was performed according to the homogeneity of variance for continuous variables.The frequency and composition ratio were used for the statistical description of classification data, and the χ 2 test or Fisher's exact test was used for comparison between groups.A p-value < 0.05 was considered to indicate significance.

Model development
Prediction models for the time of the first postoperative flatus and defecation were developed using four machine learning algorithms: logistic regression (LR), random forest (RF), Naïve Bayes (NB), and extreme gradient boosting (XGB).Data from patients undergoing colorectal surgeries from January 2015 to December 2020 were used as training sets, while data from January to October 2021 served as validation sets.We calculated the number of true-positive (TP), true-negative (TN), false-positive (FP), and false-negative (FN) results.Performance and discrimination of the prediction models were evaluated by the area under the receiver operating characteristic curve (AUC), sensitivity, specificity, positive predictive value (TP/[TP + FP]), negative predictive value (TP/ [TP + FN]), and Youden index ([sensitivity + specificity]-1).The AUC value greater than 0.6 indicated good predictive value, with closer value to 1 indicating better model performance.Nomograms based on the results of logistic regression were planned if logistic regression outperformed the other three methods.The prediction models were developed using the R software RMS package (version 4.0.3).

Baseline characteristics and related risk factors
A total of 1438 patients undergoing colorectal surgeries from January 2015 to December 2020 were involved, including 856 patients for the time of first postoperative flatus within 4 days and 1052 patients for the time of first postoperative flatus within 5 days in the training set.200 patients undergoing colorectal surgeries from January to October 2021 were involved in the validation set (Fig. 1).The mean time to postoperative flatus was 4.17 ± 1.45 days and the mean time to postoperative defecation was 4.77 ± 1.89 days.

Time of first postoperative flatus
Clinical characteristics of the patients at the time of the first postoperative flatus were shown in Table 1.Among univariate analysis, age, right colectomy, sigmoid colectomy, malignancy, hypothyroidism, preoperative anemia, preoperative ileus, ASA classification, soapsuds enema, oral laxatives, and oral antibiotic for bowel preparation, laparotomy, duration of operation, preoperative antibiotics, preoperative fortified antibiotics, time of postoperative feeding, probiotics, duration of analgesia, hypoproteinemia, time to the extraction of the gastric tube and drainage tube were associated with the time of first postoperative flatus for patients undergoing colorectal surgeries.

Time of first postoperative defecation
We investigated the variates by univariate analysis and found that 14 indicators including age, right hemicolectomy, proctectomy, encepalorrhagia, preoperative chemotherapy, ASA classification, glycerin enema for bowel preparation, oral antibiotics for bowel preparation, preoperative antibiotics, preoperative fortified antibiotics, time of first postoperative feeding, probiotics, hypoproteinemia and time to the extraction of the drainage tube were associated with that prolong the time of first postoperative defecation (Table 2).

Development of prediction models Time of first postoperative flatus
Four prediction models were conducted based on the aforementioned variables by machine learning algorithms.We used the data from January 2015 to December 2020 as a training set and the samples from January to October 2021 as a validation set.The area under the receiver operating characteristic (AUC) was 0.78(0.71-0.84) in the validation of logistic regression analysis, 0.74(0.66-0.83) in the validation of random forest (RF), 0.69(0.61-0.77) in the validation of Naïve Bayes (NB), and was 0.71(0.63-0.79) in the validation of extreme gradient boosting (XGB) for the prediction model of the time to postoperative flatus for patients undergoing colorectal surgeries (Fig. 2).Logistic regression was found to be the best-performing model for predicting the time of the first postoperative flatus comparing with the other three models as the AUC, sensitivity, specificity, positive predictive value (PPV), negative predictive value (NPV) and Youden index (sensitivity + specificity-1) were shown in Additional file 1.A nomogram was used to present the data of the time to the first postoperative flatus based on logistic regression for practical use (Fig. 3).A total number of points was calculated with age, probiotics, oral laxatives for bowel preparation, oral antibiotics for bowel preparation, duration of operation, and time of first postoperative feeding.The total score can be attached to the probability of the time to postoperative flatus (Tables 3  and 4).

Time of first postoperative defecation
In the validation set, AUCs for the LR, RF, NB, and XGB algorithms were 0.72(0.61-0.84),0.69(0.58-0.80),0.68(0.57-0.79),and 0.66 (0.54-0.77) (Fig. 4).The performance of AUC, sensitivity, specificity, PPV, NPV, and Youden index was summarized in Additional file 2. We selected the LR algorithm for the final model because the prediction model of the time to the first postoperative defecation performed well by LR.A nomogram for the time of the first postoperative defecation using by LR for patients undergoing colorectal surgeries was created based on the independent risk factors.The value of age, probiotics, oral antibiotics for bowel preparation, and time of postoperative feeding was given a score on the point scale axis in Fig. 5.A total score can be calculated by adding each score of these independent risk factors to estimate the probability of the time to the first postoperative defecation.

Postoperative complications
The incidence of postoperative complications was shown in Table 5.The symptom of abdominal distension (27.97%) contributed the highest rate of postoperative complications, while the incidence of diarrhea (27.70%) placed second to postoperative complications for patients undergoing colorectal surgeries.

Discussion
In this study, we evaluated the ability of four machine learning algorithms to predict the time of postoperative flatus and defecation for patients undergoing colorectal surgeries.Our final prediction model achieved an AUC value of 0.78(0.71-0.84)for the time of postoperative flatus and 0.72(0.61-0.84)for the time of postoperative  defecation according to the best performance of the logistic regression model compared with the other three models.The logistic regression model identified seven variables age, oral laxatives for bowel preparation, oral antibiotics for bowel preparation, probiotics, postoperative fortified antibiotics, duration of operation, and time of postoperative feeding for the time of postoperative flatus and four variables age, oral antibiotics for bowel preparation, probiotics, and time of postoperative feeding for the time of postoperative defecation.The function of the bowel is to ingest and digest food and fluids, absorb nutrients, and eliminate any waste products, which is important to understand how surgery may alter not just its anatomy, but also its function [13].Postoperative recovery is a dynamic process in that patients try to regain their independence, but postoperative bowel dysfunction is one of the most common complications among patients who have undergone major abdominal surgery [14].Urinary and sexual dysfunction are the most common complications for patients undergoing rectal surgery [15].Bowel dysfunction can manifest as constipation, anal incontinence, or diarrhea.is more likely to occur if there is a large bowel resection such as a colectomy or if most of the rectum is resected [16].Regaining normal bowel functions after surgery is considered important for patients.Bowel motion, the time of first postoperative flatus, and the time of first postoperative defecation are usually used to assess bowel function during early postoperative recovery [17].In this study, the time of postoperative flatus and defecation were selected to assess postoperative bowel function.
We found that mechanical bowel preparation with antibiotics and age were strong predictors for the risk of postoperative flatus and defecation.The mean age of the patients was 64.03 years in the study about the time of postoperative flatus and the mean age of patients with the time of postoperative flatus more than 5 days was 67.05 years in this study.Mechanical bowel preparations a BMI body mass index, b CHD coronary heart disease, c COPD chronic obstructive pulmonary disease, d ASA American Society of Anesthesiologists, e NSAIDs nonsteroidal anti-inflammatory drugs * Comparison between two groups, *group and*group.The difference between groups was statistically significant (P < 0.01 or P < 0.05)   such as soap enema and oral laxatives can reduce fecal bulk which may decrease bacterial colonization, thereby reducing the risk of postoperative complications such as anastomotic leakage and surgical site infection [18].The studies told us that mechanical bowel preparation combined with oral antibiotic bowel preparation can reduce the incidence of surgical site infection, anastomotic leakage, and other morbidity compared with mechanical bowel preparation for patients undergoing elective colorectal surgery [19][20][21][22][23]. Therefore, it was recommended that mechanical bowel preparation combined with oral antibiotic preparation for patients undergoing elective colorectal surgery in 2009 US guidelines [24].In recent years, many studies found that the potential advantages of mechanical bowel preparation combined with an oral antibiotic, such as nausea and dehydration were considered not worthwhile [25] and did not add significant value to reducing the incidence of infectious complications [26].
Probiotics and the time of postoperative feeding were predictors of reducing the time of postoperative flatus and defecation in this study.Many researchers have focused on probiotics because they found that gastrointestinal microflora plays an important role in maintaining human health [27].Probiotics help to improve the intestinal microecology balance and stimulate immunity, which may inhibit colon cancer and decrease the incidence of postoperative complications including surgical site infection, urinary tract infection, and septicemia [28][29][30].Early enteral nutrition is recommended for patients after gastrointestinal surgery [31][32][33].A study about postoperative feeding for patients undergoing colorectal surgeries found that there was no difference between patients who accepted early postoperative feeding and traditional postoperative feeding [34].Early resume to postoperative feeding helps improve clinical outcomes such as promoting bowel motility, shortening the time of postoperative defecation, and reducing intestinal mucosal hypermetabolism [35,36].
Previous studies comparing traditional open and laparoscopic surgery for rectal cancer had found that mean time about the time of postoperative flatus was 96.5 h vs 123 h [9].Recent research showed that there was no difference of time to recovery of postoperative bowel Fig. 3 Nomogram for the time of first postoperative flatus.To estimate the probability of the time of postoperative flatus, mark patient value at each axis, draw a straight line perpendicular to the point axis, and calculate the points for all variables.Then mark the sum on the total point axis and the points met the risk axis function among different site of colon [37].Another study suggested that robotic reduced-port surgery for left-sided colorectal cancer was safe and no additional benefit compared with laparoscopic surgery [38].In our study, there was no difference between laparotomy and laparoscopic surgery of colorectum for patients undergoing colorectal surgery.The Enhanced Recovery after Surgery (ERAS) protocol was well developed especially for patients undergoing the surgery treatment in laparoscopic colorectal tumor resection since the ERAS Study formed in Europe in 2001 [39].The data varied widely because there were different wards in the department of gastrointestinal surgery.More and more surgeons are following the principle of ERAS protocol for perioperative management.However, there were also someone choose traditional methods for perioperative management in our department.
In recent years, artificial intelligence has mostly narrowed down to machine learning methods.Current machine learning methods include neural networks, support vector machines, or random forests that have been used to develop prediction models and identify risk factors in recent years [40,41], but statistical models have limitations in processing numerous unrefined variables.In this study, LR showed the best performance among the other three prediction models because the assessment indicator of postoperative bowel function was limited.We believe that machine learning algorithms will be actively used as tools for predicting complex outcomes and have greater potential.
There were several limitations in this study.Firstly, the variables of the models are clinically relevant, but causality cannot be confirmed due to the nature of retrospective data.Secondly, due to retrospective design, possible collection, entry bias, and residual confounding may occur, and we did not collect the medical history of constipation.Furthermore, the risk of the time of postoperative flatus and defecation is complicated.Thirdly,   our study is a single-center study due to the lack of data from other surgical centers.We validated our model by different time at the same independent dataset, which is considered to be a kind of controversial external validation.Despite these limitations, ours is the first study to identify independent risk factors for the time of postoperative flatus and defecation in colorectal surgeries using a machine learning algorithm.

Conclusion
By means of machine learning techniques, we selected independent risk factors, as well as evaluated prediction models for the first postoperative flatus and defecation time on adult patients undergoing colorectal surgeries.
In addition, probiotics and early recovery of postoperative feeding may improve postoperative bowel function, while oral antibiotics for bowel preparation may affect postoperative bowel function for those patients.

Fig. 1
Fig. 1 Study eligibility of patients who undergone colorectal surgeries

Fig. 2
Receiver operating characteristic (ROC) curves of the prediction model for the time of first postoperative flatus conducted by machine learning algorithms

Fig. 4
Fig. 4 Receiver operating characteristic (ROC) curves for the prediction model of the time of first postoperative defecation conducted by machine learning algorithms

Fig. 5
Fig.5 Nomogram for the time of first postoperative defecation.The value of variable was given a score on the point scale axis.To estimate the risk of the time of first postoperative defecation, a total score could be calculated by each axis and could be projected to the lower total point scale

Table 1
Basic characteristics in the time of first postoperative flatus for patients undergoing colorectal surgeries

Table 2
Regression coefficients of the time of first postoperative flatus model based on 7 independent variables

Table 3
Basic characteristics in the time of first postoperative defecation for patients undergoing colorectal surgeries

Table 3
(continued) BMI body mass index, b CHD coronary heart disease, c COPD chronic obstructive pulmonary disease, d ASA American Society of Anesthesiologists, e NSAIDs nonsteroidal anti-inflammatory drugs * Comparison between two groups*group and*group.The difference between groups was statistically significant (P < 0.01 or P < 0.05) a

Table 4
Regression coefficients of the time of first postoperative defecation model based on 4 independent variables

Table 5
Postoperative complications of patients undergoing colorectal surgeries